
<template>
	<view class="content">
		
		<!-- <view class="login_img"><image mode="aspectFill" src="/static/image/iamhe.png"></image></view> -->
		<view class="login_from">
			<view class="login_from_input">
				<view class="login_from_name">用户名</view>
				<view class="login_from_fun">{{UserVo.username}}</view>
			</view>
			<view class="login_from_input">
				<view class="login_from_name">密码</view>
				<view class="login_from_fun"><input type="digit" v-model="UserVo.password" password="true" placeholder="请输入登录密码"></view>
			</view>
			<view class="login_from_input">
				<view class="login_from_name">请重新输入密码</view>
				<view class="login_from_fun"><input type="digit" v-model="UserVo.checkPassword" password="true" placeholder="请输入登录密码"></view>
			</view>
			<view class="login_from_dl">
				<button @click="denglu">修改密码</button>
			</view>	
		</view>
		
	</view>
</template>
<script>
   export default {
   data(){
     return {
		UserVo:{
			username:"",
			password:"",
			checkPassword:""
		}
		
	}
	},
    onLoad(){
		this.debau()
     },
    methods: {
		debau(){
			const value = uni.getStorageSync('userName');
			console.log(value)
			this.UserVo.username=value
			// uni.getStorage({
			//     key: 'userName',
			//     success: function (res) {
			// 		console.log(res.data)
			// 		this.UserVo.username=res.data
			//     }
			// });
		},
		denglu(){
			console.log(this.UserVo)
			uni.request({
			    url: `http://localhost:7000/user/userUpdatepassword`, //接口地址。
			    data: this.UserVo,
			    header: {
			        'custom-header': 'hello' //自定义请求头信息
			    },
				method:'POST',
			    success: (res) => {
			        console.log(res.data);
					if(res.data.flag){
						uni.showToast({
							title: '修改密码成功',
							icon: 'none',    //如果要纯文本，不要icon，将值设为'none'
							duration: 2000    //持续时间为 2秒
						}) 
						uni.navigateTo({
							url:'../login/index'
						})
					}else{
						uni.showToast({
							title: res.data.msg,
							icon: 'none',    //如果要纯文本，不要icon，将值设为'none'
							duration: 2000    //持续时间为 2秒
						})  
					}
			    }
			});	
			// uni.showModal({
			// 	    title: '友情提示',
			// 	    content: '确认修改密码吗？',
			// 	    success: function (res) {
			// 	        if (res.confirm) {
			// 	            console.log('用户点击确定');
			// 	        } else if (res.cancel) {
			// 	            console.log('用户点击取消');
			// 	        }
			// 	    }
			// 	});
		},
     }
 }
</script>
<style>
	
	page{ background: #fff; }
	
	.login_img{ width: 100%; height: auto; margin-top: 90upx; }
	.login_img image{ width: 170upx; height: 170upx; display: block; margin: 0px auto; border-radius: 50%; }
	
	.login_from{ width: 100%; height: auto; box-sizing: border-box; padding: 20upx 8%; }
	
	.login_from_input{ width: 100%; height:auto; display: flex; flex-direction: row; justify-content: space-between; align-items: center; border-bottom: 1px #eee solid; padding: 40upx 0px; margin: 0px auto;  } 
	
	.login_from_name{ width: 20%; }
	.login_from_fun{ width: 80%; display: flex; flex-direction: row; justify-content: flex-end; align-items: center;  }
	.login_from_fun input{ width: 100%; text-align: left; font-size: 14px;  }
	
	
	.login_from_dl{ width: 100%; height: 50px; line-height: 50px; margin-top: 150upx;   }
	.login_from_dl button{ width: 100%; height: 50px; line-height: 50px; background: #FF3B00; color: #fff; border-radius: 50px; }
	
	.logo_xieyi{ width: 100%; height: 40px; line-height: 40px; display: flex; flex-direction: row; margin-top: 30upx; align-items: center; color: #444; font-size: 14px; justify-content: center; }
	.logo_xieyi label{ font-size: 18px; margin-right: 1%; }
	
	.cuIcon-squarecheckfill{ color: #FF3B00; }
	.logo_text text{ color: #FF3B00; }
	
	.getyzm{ width: 60%; display: flex; flex-direction: row; justify-content: flex-end; color: #FF3B00; }
	.cuicon{ font-size: 18px; }  
	
</style>


